home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Periodicals / develop / develop 8 code / Curves in Quickdraw / QD Curves / path2pict.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-10-09  |  1.8 KB  |  82 lines  |  [TEXT/KAHL]

  1. #include <Memory.h>
  2. #include <QuickDraw.h>
  3.  
  4. #include "curves.h"
  5.  
  6. #define    POLYBEGIN    160
  7. #define    POLYEND        161
  8. #define    POLYIGNORE    163
  9. #define    POLYSMOOTH    164
  10. #define    PICPOLYCLO    165
  11.  
  12. #define    kPolyClose    4
  13. #define     kPolyFill        2
  14. #define    kPolyFrame    1
  15.  
  16. void AddSegmentToPict( curve* cur, point* delta, int isLine )
  17. {
  18.     Handle verbHdl = NewHandle( 1 );
  19.     RgnHandle origClip = NewRgn();
  20.     Rect emptyRect = { 0, 0, 0, 0 };
  21.  
  22.     **verbHdl = kPolyFrame;
  23.     GetClip( origClip );
  24.  
  25.     PicComment( POLYBEGIN, 0, 0 );
  26.     ClipRect(&emptyRect);        /* this turns drawing off */
  27.     PicComment( POLYSMOOTH, 2, verbHdl );
  28.     /*
  29.      *    Record the endpoints for Postscript
  30.      */
  31.     fmoveto( cur->start.x + delta->x, cur->start.y + delta->y );
  32.     if (isLine)
  33.         flineto( cur->end.x + delta->x, cur->end.y + delta->y );
  34.     else
  35.         flineto( cur->control.x + delta->x, cur->control.y + delta->y );
  36.     flineto( cur->end.x + delta->x, cur->end.y + delta->y );
  37.  
  38.     PicComment( POLYIGNORE, 0, 0 );
  39.     SetClip( origClip );            /* this turns drawing back on */
  40.     /*
  41.      *    Record the lines for QuickDraw
  42.      */
  43.     fmoveto( cur->start.x, cur->start.y );
  44.     if (isLine)
  45.         flineto( cur->end.x, cur->end.y );
  46.     else
  47.         FrameCurve(cur, kCurveLimit);
  48.     PicComment( POLYEND, 0, 0 );
  49.  
  50.     DisposeRgn( origClip );
  51.     DisposHandle( verbHdl );
  52. }
  53.  
  54. AddPathsToPict( paths* myPaths )
  55. {
  56.     point penDelta;
  57.     long i;
  58.     path* cont;
  59.  
  60. /*    Compute 1/2 the pen's thickness as a delta,
  61.  *    since PostScript's pen is centered, and QuickDraw's hangs to the
  62.  *    right and down.
  63. */
  64.     penDelta.x = ff(qd.thePort->pnSize.h) / 2;
  65.     penDelta.y = ff(qd.thePort->pnSize.v) / 2;
  66.  
  67.     /* Record the curve data.
  68.     */
  69.     cont = myPaths->contour;
  70.     for (i = 0; i < myPaths->contours; i++)
  71.     {    pathWalker walker;
  72.  
  73.         /*
  74.          *    This loop looks just like FramePath
  75.          */
  76.         InitPathWalker(&walker, cont);
  77.         while (NextPathSegment(&walker))
  78.             AddSegmentToPict(&walker.c, &penDelta, walker.isLine);
  79.         cont = NextPath(cont);
  80.     }
  81. }
  82.